﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using CE.Database;
public partial class Admin_user_ViewUserResultSelectedItemInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] != null && Session[CE.Global.General.UserTypeId] != null)
        {
            if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                Convert.ToInt32(CE.Global.CEUserType.SiteAdmin))
            {
                Response.Redirect("~/Admin/AdminSecureLogin.aspx");
            }
        }
        else
        {
            Response.Redirect("~/Admin/AdminSecureLogin.aspx");
        }

        if (!Page.IsPostBack)
        {
            if (Page.Request.Params["SelectedID"] != null && Page.Request.Params["SelectedType"] != null)
            {
                GetUserSelectedItemInfo(Page.Request.Params["SelectedID"].ToString(), Page.Request.Params["SelectedType"].ToString());
                GetUserRequoteQuoteInfo(Page.Request.Params["SelectedID"].ToString(), Page.Request.Params["SelectedType"].ToString());
            }
        }
    }

    private void GetUserSelectedItemInfo(string SelectedID, string SelectedType)
    {
        try
        {
            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable("Result");

            SortedList _spParaList = new SortedList();
            _spParaList.Add("@SelectedID", SelectedID);
            _spParaList.Add("@SelectedType", SelectedType);

            _dtResult = _db.GetDataTableBySP("[sprocUserSelectedHistoryResultItemSelectSingleItem]", _spParaList);
            if (_dtResult != null)
            {
                gvResultItem.DataSource = _dtResult;
                gvResultItem.DataBind();
            }
        }
        catch (Exception Ex)
        {
            Ex = null;
        }
    }

    private void GetUserRequoteQuoteInfo(string SelectedID, string SelectedType)
    {
        try
        {
            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable("Result");

            SortedList _spParaList = new SortedList();
            _spParaList.Add("@SelectedID", SelectedID);
            _spParaList.Add("@SelectedType", SelectedType);

            _dtResult = _db.GetDataTableBySP("[sprocUserRequestQuoteSelectSingleItem]", _spParaList);
            if (_dtResult != null)
            {
                gvRequestQuote.DataSource = _dtResult;
                gvRequestQuote.DataBind();
            }
        }
        catch (Exception Ex)
        {
            Ex = null;
        }
    }
}
